﻿<phone:PhoneApplicationPage
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit" 
    xmlns:tech="clr-namespace:TecHappy.WindowsPhone.Toolkit;assembly=TecHappy.WindowsPhone.Toolkit"
    
    xmlns:ec="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions" 
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" 
    xmlns:el="clr-namespace:Microsoft.Expression.Interactivity.Layout;assembly=Microsoft.Expression.Interactions" 
    x:Class="TecHappy.WindowsPhone.Sample2.MainPage" 
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800"
    SupportedOrientations="Portrait"  Orientation="Portrait"
    shell:SystemTray.IsVisible="False">
    <phone:PhoneApplicationPage.Resources>
        <DataTemplate x:Key="ColorTemplate">
            <Grid Height="240" Width="200" Background="Transparent">
                <Rectangle x:Name="Swatch" Margin="10,10,10,35" StrokeThickness="2" Stroke="Black" RenderTransformOrigin="0.5,0.5" RadiusX="5" RadiusY="5" Fill="{Binding Brush}"/>
                <TextBlock VerticalAlignment="Bottom" Margin="20,10,20,10" Foreground="White" Text="{Binding Text}" TextAlignment="Center" FontFamily="Segoe UI" FontSize="16"/>
            </Grid>
        </DataTemplate>
        <ItemsPanelTemplate x:Key="ColorListItemsPanelTemplate">
            <toolkit:WrapPanel Orientation="Horizontal">
            </toolkit:WrapPanel>
        </ItemsPanelTemplate>
        <Style x:Key="PerspectiveSwing" TargetType="ListBoxItem">
            <Setter Property="Padding" Value="3"/>
            <Setter Property="HorizontalContentAlignment" Value="Left"/>
            <Setter Property="VerticalContentAlignment" Value="Top"/>
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="TabNavigation" Value="Local"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ContentControl">
                        <Grid x:Name="grid" Loaded="grid_Loaded"  Background="{TemplateBinding Background}" RenderTransformOrigin="0.5,0.5">
                    		<Grid.RenderTransform>
                    			<CompositeTransform/>
                    		</Grid.RenderTransform>
                    		<VisualStateManager.VisualStateGroups>
                    			<VisualStateGroup x:Name="CommonStates">
                    				<VisualState x:Name="Normal"/>
                    				<VisualState x:Name="MouseOver">
                    					<Storyboard>
                    						<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="fillColor">
                    							<SplineDoubleKeyFrame KeyTime="0" Value=".35"/>
                    						</DoubleAnimationUsingKeyFrames>
                    					</Storyboard>
                    				</VisualState>
                    				<VisualState x:Name="Disabled">
                    					<Storyboard>
                    						<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="contentPresenter">
                    							<SplineDoubleKeyFrame KeyTime="0" Value=".55"/>
                    						</DoubleAnimationUsingKeyFrames>
                    					</Storyboard>
                    				</VisualState>
                    			</VisualStateGroup>
                    			<VisualStateGroup x:Name="SelectionStates">
                    				<VisualState x:Name="Unselected"/>
                    				<VisualState x:Name="Selected">
                    					<Storyboard>
                    						<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="fillColor2">
                    							<SplineDoubleKeyFrame KeyTime="0" Value=".75"/>
                    						</DoubleAnimationUsingKeyFrames>
                    					</Storyboard>
                    				</VisualState>
                    			</VisualStateGroup>
                    			<VisualStateGroup x:Name="FocusStates">
                    				<VisualState x:Name="Focused">
                    					<Storyboard>
                    						<ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="Visibility" Storyboard.TargetName="FocusVisualElement">
                    							<DiscreteObjectKeyFrame KeyTime="0">
                    								<DiscreteObjectKeyFrame.Value>
                    									<Visibility>Visible</Visibility>
                    								</DiscreteObjectKeyFrame.Value>
                    							</DiscreteObjectKeyFrame>
                    						</ObjectAnimationUsingKeyFrames>
                    					</Storyboard>
                    				</VisualState>
                    				<VisualState x:Name="Unfocused"/>
                    			</VisualStateGroup>
                    			<VisualStateGroup x:Name="LayoutStates">
                    				<VisualStateGroup.Transitions>
                    					<VisualTransition To="AfterLoaded" GeneratedDuration="0:0:0.75">
                    						<VisualTransition.GeneratedEasingFunction>
                    							<BounceEase EasingMode="EaseOut"/>
                    						</VisualTransition.GeneratedEasingFunction>
                    					</VisualTransition>
                    					<VisualTransition GeneratedDuration="0:0:0.15" From="Loaded"/>
                    					<VisualTransition GeneratedDuration="0:0:0.15"/>
                    				</VisualStateGroup.Transitions>
                    				<VisualState x:Name="BeforeLoaded">
                    					<Storyboard>
                    						<DoubleAnimationUsingKeyFrames Duration="0:0:0.001" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="grid">
                    							<EasingDoubleKeyFrame KeyTime="0" Value="-95"/>
                    						</DoubleAnimationUsingKeyFrames>
                    						<DoubleAnimation Duration="0" To="-19" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" Storyboard.TargetName="grid" d:IsOptimized="True"/>
                    					</Storyboard>
                    				</VisualState>
                    				<VisualState x:Name="AfterLoaded"/>
                    				<VisualState x:Name="BeforeUnloaded">
                    					<Storyboard>
                    						<DoubleAnimationUsingKeyFrames Duration="0:0:0.001" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="grid">
                    							<EasingDoubleKeyFrame KeyTime="0" Value="-95"/>
                    						</DoubleAnimationUsingKeyFrames>
                    					</Storyboard>
                    				</VisualState>
                    			</VisualStateGroup>
                    		</VisualStateManager.VisualStateGroups>
                    		<Grid.Projection>
                    			<PlaneProjection CenterOfRotationX="-0.1"/>
                    		</Grid.Projection>
                    		<Rectangle x:Name="fillColor" Fill="#FFBADDE9" IsHitTestVisible="False" Opacity="0" RadiusY="1" RadiusX="1"/>
                    		<Rectangle x:Name="fillColor2" Fill="#FFBADDE9" IsHitTestVisible="False" Opacity="0" RadiusY="1" RadiusX="1"/>
                    		<ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}"/>
                    		<Rectangle x:Name="FocusVisualElement" RadiusY="1" RadiusX="1" Stroke="#FF6DBDD1" StrokeThickness="1" Visibility="Collapsed"/>
                    	</Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </phone:PhoneApplicationPage.Resources>

    <!--Panorama-based applications should not show an ApplicationBar-->

    <phone:PhoneApplicationPage.FontFamily>
        <StaticResource ResourceKey="PhoneFontFamilyNormal"/>
    </phone:PhoneApplicationPage.FontFamily>
    <phone:PhoneApplicationPage.FontSize>
        <StaticResource ResourceKey="PhoneFontSizeNormal"/>
    </phone:PhoneApplicationPage.FontSize>
    <phone:PhoneApplicationPage.Foreground>
        <StaticResource ResourceKey="PhoneForegroundBrush"/>
    </phone:PhoneApplicationPage.Foreground>

    <!--LayoutRoot contains the root grid where all other page content is placed-->
    <Grid x:Name="root" d:DataContext="{Binding Source={StaticResource Pictures}}">
        <controls:Panorama Title="LayoutStates">
            <controls:PanoramaItem Header="Demo">
                <Grid>
                    <ListBox x:Name="RandomColors" Background="#FF333333" Margin="20,80,20,60"
			ItemTemplate="{StaticResource ColorTemplate}" 
            ItemsPanel="{StaticResource ColorListItemsPanelTemplate}" 
            ScrollViewer.HorizontalScrollBarVisibility="Disabled" 
            ItemContainerStyle="{StaticResource PerspectiveSwing}" 
			ItemsSource="{Binding}" BorderBrush="{x:Null}"/>
                    <Button x:Name="btnAdd" Click="btnAdd_Click" Content="+" VerticalAlignment="Top" HorizontalAlignment="Right" Margin="0,-100,80,0" Width="69" Height="69"/>
                    <Button x:Name="btnRemove" Click="btnRemove_Click" Content="-" VerticalAlignment="Top" HorizontalAlignment="Right" Margin="0,-100,0,0" Width="69" Height="69"/>
                </Grid>
            </controls:PanoramaItem>

            <!--Panorama item one-->
            <controls:PanoramaItem Header="WP7沙龙">
                <Grid Grid.Row="1" Margin="12,0,12,0">
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <TextBlock FontSize="48" HorizontalAlignment="Center" VerticalAlignment="Top"><Run Text="欢迎参加" Foreground="Yellow" FontSize="24"/><Run Text=" "/><LineBreak/><Run Text=" "/><Run Text="快乐技术沙龙"/><Run Text=" "/><LineBreak/><Run Text=" "/><Run Text="for Windows Phone 7" Foreground="Red" FontSize="30"/><Run Text=" "/><LineBreak/><Run Text=" "/><LineBreak/><Run Text=" "/><Run Text="时间: 2011年9月17日" FontSize="30"/><Run Text=" "/><LineBreak/><Run Text=" "/><Run Text="地点: 微软亚太研发集团" FontSize="30"/><Run Text=" "/><LineBreak/><Run Text=" "/><Run Text="         1层1103会议室" FontSize="30"/></TextBlock>
                </Grid>
            </controls:PanoramaItem>
        </controls:Panorama>
    </Grid>

</phone:PhoneApplicationPage>